In [1]:
import numpy as np
In [2]:
a= np.array([[1, 2, 3, 4], [4, 6, 8, 10], [9, 11, 13, 15]])
In [3]:
a
Out[3]:
In [4]:
np.gradient(a, axis=0) # along y axis
Out[4]:
In [5]:
np.gradient(a, axis=1) # along x axis
Out[5]:
In [6]:
from math import pi
In [7]:
from pygsf.spatial.rasters.fields import *
In [8]:
fld1 = array([
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1]])
In [9]:
grad_x(fld1, cell_size_x=10)
Out[9]:
In [10]:
grad_y(fld1, cell_size_y=10)
Out[10]:
In [11]:
fld2 = array([
[10, 10, 10, 10],
[20, 20, 20, 20],
[30, 30, 30, 30]])
In [12]:
grad_x(fld2, cell_size_x=10)
Out[12]:
In [13]:
grad_y(fld2, cell_size_y=10)
Out[13]:
In [14]:
dir_deriv(fld2, cell_size_x=10, cell_size_y=10, direct_rad=pi*45.0/180.0)
Out[14]:
In [15]:
dir_deriv(fld2, cell_size_x=10, cell_size_y=10, direct_rad=pi*0.0/180.0)
Out[15]:
In [16]:
dir_deriv(fld2, cell_size_x=10, cell_size_y=10, direct_rad=pi*180.0/180.0)
Out[16]:
In [17]:
dir_deriv(fld2, cell_size_x=10, cell_size_y=10, direct_rad=pi*90.0/180.0)
Out[17]:
In [18]:
dir_deriv(fld2, cell_size_x=10, cell_size_y=10, direct_rad=pi*270.0/180.0)
Out[18]:
In [19]:
dir_deriv(fld2, cell_size_x=10, cell_size_y=10, direct_rad=pi*315.0/180.0)
Out[19]:
In [20]:
dir_deriv(fld2, cell_size_x=10, cell_size_y=10, direct_rad=pi*135.0/180.0)
Out[20]:
In [21]:
fld3 = array([
[10, 10, 10, 10],
[20, 20, 20, 20],
[30, 30, 30, 30]])
In [22]:
fld4 = fld3
In [23]:
orients_d(fld3, fld4)
Out[23]:
In [24]:
orients_d(fld3, -fld4)
Out[24]:
In [25]:
orients_d(-fld3, fld4)
Out[25]:
In [26]:
orients_d(-fld3, -fld4)
Out[26]:
In [27]:
orients_d(fld3, 0.0)
Out[27]:
In [28]:
orients_d(0, fld4)
Out[28]:
In [29]:
orients_d(0, -fld4)
Out[29]:
In [30]:
orients_d(-fld3, 0.0)
Out[30]: